class Solution {
public:
    string longestPalindrome(string s) {
        string tmp;
        for(int i=0;i<s.size();++i)
        {
            int left=i;
            int right=i;
            while(left>=0&&right<=s.size()-1&&s[left]==s[right])
            {
                left--;
                right++;
            }
            if(tmp.size()<(right-left-1))
            {
               tmp=s.substr(left+1,right-left-1);
            }

            left=i;
            right=i+1;
            while(left>=0&&right<=s.size()-1&&s[left]==s[right])
            {
                left--;
                right++;
            }
            if(tmp.size()<(right-left-1))
            {
               tmp=s.substr(left+1,right-left-1);
            }
        }
        return tmp;
    }
};
